<?php
include_once("uitilities.php");
include_once("../Business/facebook_app_service.php");
include_once("../Business/Data/Entity/facebook_app.php");
include_once '../Business/Data/Constants.php';
$f =null;
$app_id = get('app_id');
$survey_id=get('survey_id');
if($app_id){
	$f  = facebook_app_service::get_facebook_app($app_id);
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
	$survey_id = post('survey_id');
	$f  = new facebook_app(post("app_id"),post("app_api_key"),post("app_secret"));
	facebook_app_service::update_facebook_app($f);
	$msg ='Update facdebook App successfully';
	
}

$main_content = '
<form method="post">
<center>
<p class="label-submit">
	<input value="Update facebook app" type="submit" title="Update facebook app">
</p>
</center>
<h3>Facebook app</h3>	
    <table class="survey">
        <tbody>
            <tr class="even">
                <td>
                    <dl>
                        <dt>app apikey</dt>
                    </dl>
                </td>
                <td>
                    <input type="text" name="app_api_key" value="'.$f->app_api_key.'" />
                </td>
            </tr>
            <tr >
                <td>
                    <dl>
                        <dt>app secret</dt>
                    </dl>
                </td>
                <td>
                    <input type="text" name="app_secret" value="'.$f->app_secret.'" />
                </td>
            </tr>
            <tr >
                <td>
                    <dl>
                        <dt>Canvas callback url </dt>
                    </dl>
                </td>
                <td>
                    <label>'.Constants::$facebook_url.$survey_id.'/</label>
                </td>
            </tr>
        </tbody>
    </table>
	<center>
	<p class="label-submit">
		<input value="Update facebook app" type="submit" title="Update facebook app">
	</p>
	</center>
	<input type="hidden" name="app_id" value="'.$f->app_id.'">
	<input type="hidden" name="survey_id" value="'.$survey_id.'">
</form>';
include_once("masters/pages.php");

?>